﻿<?php $clientModel = new Admin_Model_Clients();?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3"><?php echo $this->partial('choix/menu.phtml') ?></div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
				<?php
					$row = $clientModel->getClientById($this->num);
					$row_vente = $clientModel->getClientVentes($this->num, $this->num_vente);
				?>
				
					<form action="<?php echo $this->baseUrl()?>/admin/clients/update-client?num=<?php echo $this->num;?>&org=<?php echo $this->org;?>&num_vente=<?php echo $this->num_vente?>" method="post" name="formCli">
					<!--
					<?php if($this->org == "all") { ?>
						<p align="center"><input name="btn_prev" type="image" value="previous" src="images/gauche.png" onclick="document.formCli.submit()" class="chk" /> <input name="btn_next" type="image" value="next" src="images/droite.png" onclick="document.formCli.submit()" class="chk" /></p>
					<?php } ?>
					
					<p align="center"><a href="#" onclick="voir('fiche_client_pdf','<?php echo $this->num ?>','','','<?php echo $this->num_vente ?>')">Fichier PDF</a></p>
					-->
					  <table align="center" cellpadding="3" cellspacing="0" class="tbl" width="80%">
						<thead>
						<tr>
							<th colspan="6" class="titre-form" align="center">Edition d'un client</th>
						</tr>
						</thead>
						<tr>
							<td style="text-align:left">Type de client :</td>
							<td style="text-align:left">
								<input name="vendeur" type="checkbox" class="chk" id="vendeur" onclick="typeCli()" value="1" <?php if($row['vendeur'] == 1) { echo " checked"; } ?> />
								Vendeur&nbsp;&nbsp;
								<input name="acheteur" type="checkbox" class="chk" id="acheteur" onclick="typeCli()" value="1" <?php if($row['acheteur'] == 1) { echo " checked"; } ?> />
								Acheteur&nbsp;&nbsp;
								<input name="contact" type="checkbox" class="chk" id="contact" onclick="typeCli()" value="1" <?php if($row['contact'] == 1) { echo " checked"; } ?> />
								Contact
							</td>
							<td style="text-align:left">N&deg;</td>
							<td colspan="3" style="text-align:left">
								<input type="text" name="num_client" value="<?php echo ($row_vente['num_client'] != 'n')? (int)$row_vente['num_client'] : $row_vente['num_client'];?>" size="4" maxlength="45"/>
							</td>
						</tr>
						<tr>
							<td style="text-align:left">Catégorie :</td>
							<td style="text-align:left">
								<input name="bd" type="checkbox" class="chk" id="checkbox" value="1" <?php if($row['bd'] == 1) { echo " checked"; } ?> />
								BD&nbsp;&nbsp;
								<input name="obj" type="checkbox" class="chk" id="checkbox" value="1" <?php if($row['obj'] == 1) { echo " checked"; } ?> />
								Objet&nbsp;&nbsp;
								<input name="fg" type="checkbox" class="chk" id="checkbox" value="1" <?php if($row['fg'] == 1) { echo " checked"; } ?> />
								Fond de grenier
							</td>
							<td style="text-align:left">%Com : </td>
							<td style="text-align:left"><input name="commission" type="text" id="commission" size="4" maxlength="4" value="<?php echo $row_vente['commission'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">Civilit&eacute; :</td>
							<td style="text-align:left">
								<select name="civilite">
								<?php
									$selected = '';
									$listCity = $clientModel->getListCity();
									foreach($listCity as $city) :
										if ($city->p_civilites == $row['f_civilites']) $selected = 'selected';
										else $selected = '';
								?>	
										<option value="<?php echo $city['p_civilites']?>" <?php echo $selected?>><?php echo $city['nom']?></option>
								<?php endforeach;?>
								</select>
							</td>
							<td style="text-align:left">Nom :</td>
							<td colspan="3" style="text-align:left"><input name="nom" type="text" id="nom" size="50" value="<?php echo stripslashes($row['nom']) ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">Pr&eacute;nom :</td>
							<td><input name="prenom" type="text" id="prenom2" size="50" value="<?php echo stripslashes($row['prenom']) ?>" /></td>
							<td style="text-align:left">c/o :</td>
							<td colspan="3" style="text-align:left"><input name="co" type="text" id="co" size="50" value="<?php echo stripslashes($row['co']) ?>" /></td>
						</tr>
						<tr>
						  <td style="text-align:left">Adresse :</td>
						  <td style="text-align:left"><input name="adresse" type="text" id="adresse" size="50" value="<?php echo stripslashes($row['adresse']) ?>" /></td>
						  <td style="text-align:left">Adresse (suite) :</td>
						  <td colspan="3" style="text-align:left"><input name="adresse2" type="text" id="adresse3" size="50" value="<?php echo stripslashes($row['adresse2']) ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">Code Postal :</td>
							<td style="text-align:left"><input type="text" name="cp" id="cp2" value="<?php echo $row['cp'] ?>" /></td>
							<td style="text-align:left">Ville : </td>
							<td colspan="3" style="text-align:left"><input name="ville" type="text" id="ville" size="50" value="<?php echo stripslashes($row['ville']) ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">Pays :</td>
							<td style="text-align:left">
								<select name="pays">
								<?php
									$listPay = $clientModel->getListPay();
									$selected='';
									foreach($listPay as $pay) :
										if ($pay['p_pays'] == $row['f_pays']) $selected = " selected";
										else $selected='';
										
								?>	
										<option value="<?php echo $pay['p_pays']?>" <?php echo $selected ?>><?php echo $pay['nom']&nbsp;?></option>;
									<?php endforeach;?>		
								</select>
							</td>
							<td style="text-align:left">T&eacute;l 1 :</td>
							<td colspan="3" style="text-align:left"><input name="tel1" type="text" id="tel1" size="30" value="<?php echo $row['tel1'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">T&eacute;l 2 :</td>
							<td style="text-align:left"><input name="tel2" type="text" id="tel2" size="30" value="<?php echo $row['tel2'] ?>" /></td>
							<td style="text-align:left">T&eacute;l 3 :</td>
							<td colspan="3" style="text-align:left"><input name="tel3" type="text" id="tel3" size="30" value="<?php echo $row['tel3'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">T&eacute;l 4 :</td>
							<td style="text-align:left"><input name="tel4" type="text" id="tel4" size="30" value="<?php echo $row['tel4'] ?>" /></td>
							<td style="text-align:left">N&deg; Compte :</td>
							<td colspan="3" style="text-align:left"><input name="banque" type="text" id="banque" size="30" value="<?php echo $row['compte_banque'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">N&deg; Carte identit&eacute; :</td>
							<td style="text-align:left"><input name="identite" type="text" id="identite" size="50" value="<?php echo $row['num_identite'] ?>" /></td>
							<td style="text-align:left">Email : </td>
							<td colspan="3" style="text-align:left"><input name="email" type="text" id="email" size="50" value="<?php echo $row['email'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">N&deg; TVA :</td>
							<td style="text-align:left"><input name="tva" type="text" id="tva" size="30" value="<?php echo $row['tva'] ?>" /></td>
							<td style="text-align:left">UserID :</td>
							<td colspan="3" style="text-align:left"><input name="userid" type="text" id="userid" size="30" value="<?php echo $row['userid'] ?>" /></td>
						</tr>
						<tr>
							<td style="text-align:left">Archiver :</td>
							<td style="text-align:left"><input name="archive" type="checkbox" class="chk" id="checkbox" value="1" <?php if($row['archive'] == 1) { echo " checked"; } ?> /></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td style="text-align:left">Catalogue d'office ?</td>
							<td style="text-align:left"><input name="catoffice" type="radio" value="0" <?php if($row['catoffice'] == 0) { echo " checked"; } ?> class="chk" /> Non <input name="catoffice" type="radio" value="1" <?php if($row['catoffice'] == 1) { echo " checked"; } ?> class="chk" /> Oui</td>
							<td style="text-align:left">Contacter vente dépôt</td>
							<td style="text-align:left"><input name="contact_depot" type="radio" value="0" <?php if($row['contact_depot'] == 0) { echo " checked"; } ?> class="chk" /> Non <input name="contact_depot" type="radio" value="1" <?php if($row['contact_depot'] == 1) { echo " checked"; } ?> class="chk" /> Oui</td>
						</tr>
						<tr>
							<td align="right" valign="top">L'utilisateur</td>
							<td valign="top">
							<?php
								if ($row['dtconfirm'] == "") echo "n'a pas encore";  
								else echo "a ";  
								echo " confirmé son inscription";
							?>
							</td>
							<td align="right" valign="top">Banque dessin&eacute;e</td>
							<td colspan="3">		  
							<?php
							if ($row['dtvalid'] == "") echo "n'a pas encore";  
							else echo "a ";  
							echo " validé son inscription<br>";
							if ($row['dtvalid'] == "") :
								if ($row['dtdemandevalid'] != "") {
									echo "L'utilisateur a demandé sa validation le " . dtformatfromdb($row->dtdemandevalid,"DD/MM/YYYY") . " à " . $row->hrdemandevalid. "<br>";
								}			  
							?>
								Autoriser cet utilisateur à placer des ordres d'achats ?  
								<select name="valid">
									<option value="0">Non</option>
									<option value="1">Oui</option>
								</select>
							<?php else : ?>
								<br />Retirer la validation ?&nbsp;
								<select name="valid">
									<option value="0">Non</option>
									<option value="19000101">Oui</option>
								</select>
							<?php endif;?>
							</td>
						</tr>
						<tr>
							<td colspan="6" align="center"><input name="sauver" type="submit" class="btn btn-primary" value=" Sauver " /></td>
						</tr>
					</table>
					</form>
				</div>
            </div>
        </div>
    </div>
</div>